<?php

namespace app\common\model;


class ShopGroupbuyModel extends BaseModel
{
    protected $name = 'shop_groupbuy'; //定义用户表
    //开启自动写入时间戳
    protected $autoWriteTimestamp = false;
    // 定义自动完成的属性
    protected $auto = []; //新增修改
    protected $insert = []; //插入
    protected $update = []; //修改

    protected function getStatusTextAttr($value, $data)
    {
        $status = [0=>'取消',1=>'正常',2=>'结束'];
        return $status[$data['status']];
    }
    protected function getGroupbuyContentAttr($value)
    {
        return stripslashes(htmlspecialchars_decode($value));
    }
    /**
     * 店铺商品价格
     * @param $value
     * @param $data
     * @return mixed
     */
    protected function getSimplePriceAttr($value, $data)
    {
        $goodsSkuModel = new ShopGoodsSkuModel();
        $goodsPrice = $goodsSkuModel->where('sku_id',$data['sku_id'])->value('goods_price');
        $goodsPrice = format_goods_price($goodsPrice);
        return $goodsPrice['simple_price'];
    }
}